package com.yuan.zsschool.ui;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;

import com.yuan.base.framework.BaseFrameworkActivity;
import com.yuan.base.framework.image.BaseImageLoad;
import com.yuan.zsschool.R;
import com.yuan.zsschool.bean.AttachFile;
import com.yuan.zsschool.common.photoView.PhotoView;


/**
 * 大图展示
 * @version 1.0
 */
public class ShowImageActivity extends BaseFrameworkActivity {
	// --------------------------控件--------------------------
	private PhotoView image;
	// --------------------------变量--------------------------
	private AttachFile gridImg;

	@Override
	protected int getLayoutId() {
		return R.layout.activity_show_image;
	}

	@Override
	protected void bindViews() {
		image = findViewById(R.id.image);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		gridImg = getIntent().getParcelableExtra("gridImg");

		BaseImageLoad.load(gridImg.getId(), image);
		image.enable();
		image.setOnClickListener(v -> closeSelf());
	}

	@Override
	public void closeSelf() {
		super.closeSelf();
		overridePendingTransition(0, R.anim.base_image_out);
	}

	public static void showImgById(Context context, String imageId) {
		if (TextUtils.isEmpty(imageId)) {
			return;
		}
		AttachFile svAttachFile = new AttachFile();
		svAttachFile.setId(imageId);
		Intent intent = new Intent(context, ShowImageActivity.class);
		intent.putExtra("gridImg", svAttachFile);
		context.startActivity(intent);
	}


}
